const fs = require('fs');

function registerRouters(app) {
    // 1. 读取当前文件夹下的所有文件
    const files = fs.readdirSync(__dirname);
    // 遍历文件
    for (let file of files) {
        if (!file.endsWith('.router.js')) continue;
        const router = require(`./${file}`)
        // console.log(router);
        app.use(router.routes());
        app.use(router.allowedMethods())
    }

}

module.exports = registerRouters